package com.digital.smartgrow.service.title;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.digital.smartgrow.dao.title.WholeMapper;
import com.digital.smartgrow.dto.title.Whole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class WholeServiceImpl implements WholeService{


    @Autowired
    WholeMapper wholeMapper;

    @Override
    @Transactional
    public List<Whole> findList(Whole whole) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("idcard", whole.getIdcard());
        return wholeMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional
    public void update(Whole whole) {
        Whole whole1 = new Whole();
        Date date =new Date();
        whole1.setId(whole.getId()).setIdcard(whole.getIdcard()).setAchievement(whole.getAchievement())
                .setAchievements(whole.getAchievements()).setGuidance(whole.getGuidance()).setReform(whole.getReform())
                .setResponsibilities(whole.getResponsibilities()).setSummary(whole.getSummary()).setTime(date)
                .setWorkingconditions(whole.getWorkingconditions());
         wholeMapper.updateById(whole1);
    }
}
